import os
import subprocess
import sys

defaultRoot = r'C:\temp\NDUSandbox\Release'

def GenCMD(arrayAddress):
    fileNames = os.listdir(defaultRoot)
    cmdStr = r'naviseccli.exe -h ' + arrayAddress + ' -user a -password a -scope 0 ndu -install '
    for item in fileNames:
        cmdStr = cmdStr + os.path.join(defaultRoot, item) + ' '
    cmdStr += '-force -skiprules'
    return cmdStr

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print('Error: Please input the array ip address!')
    command = GenCMD(sys.argv[1])
    print(command)
    
    #subTask = os.popen(command)
    #print(subTask.read())
    
